//
//  LogindViewController.m
//  App-MyFairldy
//
//  Created by 客官大大 on 15/5/26.
//  Copyright (c) 2015年 客官大大. All rights reserved.
//

#import "LogindViewController.h"
#import "UMSocial.h"
#import "UMSocialSinaHandler.h"
#import "UMSocialSinaSSOHandler.h"

@interface LogindViewController ()

@end

@implementation LogindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, 100, 100, 30);
    [button setTitle:@"微信登录" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button.layer.borderColor = [UIColor blackColor].CGColor;

    [button addTarget:self action:@selector(touchi1) forControlEvents:UIControlEventTouchUpInside];
    button.layer.borderWidth = 1;
    button.layer.cornerRadius = 10;
    
    [self.view addSubview:button];
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(100, 300, 100, 30);
    [button1 setTitle:@"微博登录" forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button1.layer.borderColor = [UIColor blackColor].CGColor;
        [button1 addTarget:self action:@selector(touchi2) forControlEvents:UIControlEventTouchUpInside];
    button1.layer.borderWidth = 1;
    button1.layer.cornerRadius = 10;
    [self.view addSubview:button1];
    
   


    
    
    
}

-(void)touchi1
{
   [UMSocialSinaHandler openSSOWithRedirectURL:@"http://www.yshow.net"];
    NSString *platftname = [UMSocialSnsPlatformManager getSnsPlatformString:UMSocialSnsTypeSina];
    UMSocialSnsPlatform *snsplatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
    snsplatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
        NSLog(@"response is %@",response);
        if (response.responseCode == UMSResponseCodeSuccess) {
            UMSocialAccountEntity *snsaccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:platftname];
            NSLog(@"=====%@",snsaccount.accessToken);
        }
        
    });
}
-(void)touchi2
{NSLog(@"SDAD");
//    NSString *platformName = [UMSocialSnsPlatformManager getSnsPlatformString:UMSocialSnsTypeMobileQQ];
//  
//    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToQQ];
//
//    snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
//       
//        NSLog(@"login response is %@",response);
//     
//        //获取微博用户名、uid、token等
//     
//        if (response.responseCode == UMSResponseCodeSuccess) {
//       
//            UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:platformName];
//      
//            NSLog(@"username is %@, uid is %@, token is %@,iconUrl is %@",snsAccount.userName,snsAccount.usid,snsAccount.accessToken,snsAccount.iconURL);
//        
//        }
//      
//    });
    [UMSocialSinaHandler openSSOWithRedirectURL:@"http://www.yshow.net"];
    NSString *platftname = [UMSocialSnsPlatformManager getSnsPlatformString:UMSocialSnsTypeSina];
    UMSocialSnsPlatform *snsplatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
    snsplatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
        NSLog(@"response is %@",response);
        if (response.responseCode == UMSResponseCodeSuccess) {
            UMSocialAccountEntity *snsaccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:platftname];
            NSLog(@"=====%@",snsaccount.accessToken);
        }
        
    });
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
